#!/usr/bin/python3
# -*- coding: utf-8 -*-

import pandas as pd
import numpy  as np
import talib as ta

eps = 1e-8

def signal(*args):
    # Rbias
    df = args[0]
    n = args[1]
    factor_name = args[2]

    ma = df['close'].rolling(n, min_periods=1).mean()
    df[factor_name] = (df['close'] / ma) / (df['close'].shift(1)/ma.shift(1)) - 1

    return df
